package patterns.factoryPattern;

import java.util.ArrayList;
import java.util.List;

public abstract class SellArea {
	List<String> selfBookStores = new ArrayList<>();
	List<String> otherBookStores = new ArrayList<>();

	final int saySelfBookStoreNumber() {
		return selfBookStores.size();
	}

	final int sayOtherBookStoreNumber() {
		return otherBookStores.size();
	}

	final String saySelfBookStoreNames() {
		return list2String(selfBookStores);
	}

	final String sayOtherBookStoreNames() {
		return list2String(otherBookStores);
	}

	private final String list2String(List<?> list) {
		StringBuffer sb = new StringBuffer();
		sb.append("{");
		for (int i = 0; i < list.size(); i++) {
			sb.append(list.get(i));
			if (i < list.size() - 1)
				sb.append(",");
		}
		sb.append("}");
		return sb.toString();
	}
}
